package com.hama.zea.util.thread;

public class Test implements Runnable{

	public static void main(String[] args) throws InterruptedException {
		Thread t=new Thread(new Test(),"hama");//new state
		System.out.println("hama change to start");
		t.start();//change to runnable
		Thread.sleep(3000);
		System.out.println("interrupt ...");
		t.interrupt();//interrupt this thread
		System.out.println("is interrupt?===>"+t.isInterrupted());
		Thread.sleep(3000);
		System.out.println("stop!");
	}
	
	@Override
	public void run() {

		boolean flag=false;
		while (!flag) {
			System.out.println(Thread.currentThread().getName()+" hama is running...");
			long time=System.currentTimeMillis();
			while ((System.currentTimeMillis()-time)<1000) {
				
			}
			/*if(Thread.currentThread().isInterrupted()){
				break;
			}*/
		}
		System.out.println("hama exiting under request");
	}

}
